]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
StTheme: retrive the list of custom stylesheets and use it in loadTheme()
authorGiovanni Campagna <gcampagna@src.gnome.org>
Thu, 2 Jun 2011 15:05:08 +0000 (17:05 +0200)
committerGiovanni Campagna <gcampagna@src.gnome.org>
Wed, 15 Jun 2011 19:56:37 +0000 (21:56 +0200)
Using the list of stylesheets loaded with st_theme_load_stylesheet(),
one can build an StTheme that is completely identical to the previous
one, except for one property (application-stylesheet).
This allows rt and the user-theme extension to work while respecting
the theming of other extensions.

https://bugzilla.gnome.org/show_bug.cgi?id=650971

js/ui/main.js
src/st/st-theme.c
src/st/st-theme.h

index 1d27b4cb1d8550dce402605c3fc02aa726eb1dfb..c0f48451a0a841ac7dd2d1c58125573a6ee2c564 100644 (file)
@@ -393,12 +393,21 @@ function setThemeStylesheet(cssStylesheet)
  */
 function loadTheme() {
     let themeContext = St.ThemeContext.get_for_stage (global.stage);
+    let previousTheme = themeContext.get_theme();
 
     let cssStylesheet = _defaultCssStylesheet;
     if (_cssStylesheet != null)
         cssStylesheet = _cssStylesheet;
 
     let theme = new St.Theme ({ application_stylesheet: cssStylesheet });
+
+    if (previousTheme) {
+        let customStylesheets = previousTheme.get_custom_stylesheets();
+
+        for (let i = 0; i < customStylesheets.length; i++)
+            theme.load_stylesheet(customStylesheets[i]);
+    }
+
     themeContext.set_theme (theme);
 }
 
index 326d9def937d02541871d0aa3b7aaf65c37ab794..2058e32f1a4f564b88ddcc2528c852555397f5c4 100644 (file)
@@ -256,6 +256,30 @@ st_theme_unload_stylesheet (StTheme    *theme,
   cr_stylesheet_unref (stylesheet);
 }
 
+/**
+ * st_theme_get_custom_stylesheets:
+ * @theme: an #StTheme
+ *
+ * Returns: (transfer full) (element-type utf8): the list of stylesheet filenames
+ *          that were loaded with st_theme_load_stylesheet()
+ */
+GSList*
+st_theme_get_custom_stylesheets (StTheme *theme)
+{
+  GSList *result = NULL;
+  GSList *iter;
+
+  for (iter = theme->custom_stylesheets; iter; iter = iter->next)
+    {
+      CRStyleSheet *stylesheet = iter->data;
+      gchar *filename = g_hash_table_lookup (theme->filenames_by_stylesheet, stylesheet);
+
+      result = g_slist_prepend (result, g_strdup (filename));
+    }
+
+  return result;
+}
+
 static GObject *
 st_theme_constructor (GType                  type,
                       guint                  n_construct_properties,
index 003c2a7c1c8402f1503bc6c038945907a6ce694c..0a044bf3e62303ff599fadb4ff3b375ca1ead4ad 100644 (file)
@@ -51,9 +51,9 @@ StTheme *st_theme_new (const char *application_stylesheet,
                        const char *theme_stylesheet,
                        const char *default_stylesheet);
 
-gboolean st_theme_load_stylesheet (StTheme *theme, const char *path, GError **error);
-
-void st_theme_unload_stylesheet (StTheme *theme, const char *path);
+gboolean  st_theme_load_stylesheet        (StTheme *theme, const char *path, GError **error);
+void      st_theme_unload_stylesheet      (StTheme *theme, const char *path);
+GSList   *st_theme_get_custom_stylesheets (StTheme *theme);
 
 G_END_DECLS